/**
 * ...
 * @author HTML5
 */

function Animation() 
{
	this.data = new Array();
}

Animation.prototype.data = null;
Animation.prototype.frame = 0;
Animation.prototype.sprite = null;
Animation.prototype.animationTime = 16;
Animation.prototype._lastTime = 0;

Animation.prototype.setFrame = function( p_frameId, p_uv, p_textureId ) 
{
	this.data[p_frameId] = {"uv":p_uv,"tex":p_textureId};
};

Animation.prototype.animate = function( p_time )
{
	if( p_time - this._lastTime < this.animationTime )
	{
		return;
	}
	
	this._lastTime = p_time;
	var frameObj = null;
	this.frame++;
	
	if( this.frame == this.data.length )
	{
		this.frame = 0;
	}
	
	frameObj = this.data[this.frame];
	
	this.sprite.uv 			= frameObj.uv;
	this.sprite.textureId 	= frameObj.tex;
};

Animation.prototype.destroy = function()
{
	this.data = null;
};